#include "src/ltt.h"

#include <stddef.h>
#include <stdint.h>

#include "src/ltbase.h"
#include "src/ltlog.h"
#include "src/ltt_testcase.h"

lt_UsingType(lt, U32);
lt_UsingType(lt, USize);
lt_UsingType(ltt, TestCase);

int
ltt_Run(void) {
    TestCase** testcase = ltt_GetTestCases();

    int r = 0;
    for (USize i = 0; testcase[i] != NULL; ++i) {
        ltlog_Log1(Info, "run test", "name", String(testcase[i]->name));

        int rtmp = testcase[i]->func();
        if (rtmp != 0) {
            ltlog_Log1(Error, "test failed", "name", String(testcase[i]->name));
            r = rtmp;
        }
    }

    if (r == 0)
        ltlog_Log0(Info, "all the tests were successful");

    return r;
}
